#!/bin/sh

source config

chapter=`ls -l  $tag*.md |sed -e "/^l/d" |wc |awk '{print $1}'`

for files in `no $chapter`
do
	str=$tag$files"_"

	chaptername=`ls -l $str*.md |sed -e "/^l/d" |awk '{print $NF}'`

	readay=`ls -l $str*.md |wc |awk '{print $1}'`

	period=`ls $str*.md |sed -e "s/.*_//g" |sed -e "s/-.*//g" |awk '{printf $0 " " }' |awk  '{print $1 " " $NF}' |sed -e "s/ /-/g" `

	grep "^###### 阅读日期：" $chaptername

	if [ $? -ne 0 ]; then
		echo "###### 阅读日期：" $period " 共：" $readay "天" >> $chaptername
	else
		echo "alread add readay "
	fi

done
